<?php

/**
 * @author Terry & 千里孤坟
 * @copyright 2009
 */

/**
* 主动攻击技能基类
*/
class Skill {
	
	public function __construct() {
		$this->id = -1;
		$this->name = "攻击基类";			//技能名称
		$this->type = 0;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->tp = 0;
	}
	
	//特殊Start处理，如地形影响
	public function pre_attack($sk,$a,$b) {
	
	}

	public function spec_kill_desc($a,$b) {
		if($a->cid == 36) {
			if($b->cid == 1) {
				$_SESSION['show'] .= "小姑娘，你还太嫩了，还需要继续修炼呢<br>。";
			} elseif($b->cid == 143) {
				$_SESSION['show'] .= "精灵之主，果然是不好对付的对手。你的意志，我见识到了。<br>";
			} elseif($b->cid == 145 || $b->cid ==120) {
				$_SESSION['show'] .= "不愧是我看中的男人，有机会一起战斗吧。<br>";
			} elseif($b->cid == 99) {
				$_SESSION['show'] .= "不断轮回的因果律，究竟何时能结束呢。<br>";
			} elseif($b->cid == 107 || $b->cid == 129 || $b->cid == 25) {
				$_SESSION['show'] .= "注意素质！<br>";
			} elseif($b->cid == 114) {
				$_SESSION['show'] .= "没想到会有这么一天……<br>";
			}						
		}
		if($a->cid == 143 && $b->cid == 1) {
			$_SESSION['show'] .= $a->name."对着".$b->name."的脑袋手刀猛敲：笨蛋笨蛋大笨蛋！<br>";
		}
		if($a->cid == 122 && $b->cid == 120) {
			$_SESSION['show'] .= $a->name."：相识总是短暂的，我们只是缘尽了。<br>";
		}
		if($b->cid == 143) {
			if($a->cid == 36) {
				$_SESSION['show'] .= $b->name."仰天高呼：天不助我！<br>";
			} elseif($a->cid == 120) {
				$_SESSION['show'] .= $b->name."雪飘撇了撇嘴：".$a->name."大哥哥最讨厌了<br>";
			}
		}
		if($a->cid == 143 && $b->cid == 145) {
			$_SESSION['show'] .= $a->name."朝天空撒出了一把红心扑克牌：“明年今日，再来看你”<br>";
		}
		if($a->cid == 128 && $b->cid == 143) {
			$_SESSION['show'] .= "-------<br>".$a->name."温柔地把".$b->name."按倒在地<br>我的爱人，和我一起在血海中沉沦吧<br>";
		}
		if($b->cid == 43) {
			$_SESSION['show'] .= "大家……对不起，莉莉先走一步……<br>";
			CalHelper::cgdisplay('lili_9.jpg');
		}
		if($a->cid == 56) {
			$_SESSION['show'] .= "永别了，这一切都是为了我的君主。吾等将以火焰更新这个世界。<br>";
		}
		if($a->gender == 0 && SkillHelper::isphyskill($this) && $this->pwr >= 250 && $b->cid == 123) {
			CalHelper::cgdisplay('slili_hurt.jpg');
		}
		if($a->cid == 24 && in_array($b->cid,array(10,51,85))) {
			$_SESSION['show'] .= "难道只有剩下骸骨的时候，你，才愿意拥抱我吗？<br>";
			CalHelper::cgdisplay('sing_killmale.jpg');
		}
		if($b->cid == 24) {
			$_SESSION['show'] .= "我会在冥府，永远等着你，哈哈哈……<br>";
			CalHelper::cgdisplay('sing_die.jpg');
		}
		if($b->cid == 1) {
			$_SESSION['show'] .= "<br>啊啊，今次是我的败北吗？<br>那么，就此化为泡沫也不错呢……<br>可别忘记了，这场战斗，仅仅是一个开始而已<br>";
			CalHelper::cgdisplay('teaplum_15.jpg');
		}
		if($a->cid == 105) {
			CalHelper::cgdisplay('gsilver_ko.jpg');
		}
	}
	
	public function kill_desc($a,$b) {
		switch($this->atk_type) {
		case 0:{$_SESSION['show'] .= $b->name."力尽。<br>";break;}
		case 1:{$_SESSION['show'] .= $b->name."被烧死了。<br>";break;}
		case 2:{$_SESSION['show'] .= $b->name."被冻成冰块。<br>";break;}
		case 3:{$_SESSION['show'] .= $b->name."被电成焦炭。<br>";break;}
		case 4:{$_SESSION['show'] .= $b->name."被大地吞没。<br>";break;}
		case 5:{$_SESSION['show'] .= $b->name."被风力撕碎。<br>";break;}
		case 6:{$_SESSION['show'] .= $b->name."在光芒中融化。<br>";break;}
		case 7:{$_SESSION['show'] .= $b->name."被黑暗吞噬。<br>";break;}
		case 8:{$_SESSION['show'] .= $b->name."肉体坏灭。<br>";break;}
		}
	}

	public function suicide_desc($a) {
		if($a->atkskill_status[25]->on == 1 && $this->atk_type == 0) {
			$_SESSION['show'] .= $a->name."的枪尖深深插入了自己的心脏。<br>";
			return 0;
		}
		switch($this->atk_type) {
		case 0:{$_SESSION['show'] .= $a->name."的攻击被反射，致死。<br>";break;}
		case 1:{$_SESSION['show'] .= $a->name."玩火自焚了……<br>";break;}
		case 2:{$_SESSION['show'] .= $a->name."被冻成冰块。<br>";break;}
		case 3:{$_SESSION['show'] .= $a->name."被自己的雷劈死了。<br>";break;}
		case 4:{$_SESSION['show'] .= $a->name."被大地吞没。<br>";break;}
		case 5:{$_SESSION['show'] .= $a->name."被风力撕碎。<br>";break;}
		case 6:{$_SESSION['show'] .= $a->name."在光芒中融化。<br>";break;}
		case 7:{$_SESSION['show'] .= $a->name."被黑暗吞噬。<br>";break;}
		case 8:{$_SESSION['show'] .= $a->name."肉体坏灭。<br>";break;}
		}
	}

	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid]);
	}

	public function checkex($a) {
		if(isset($this->excid) && in_array($a->cid,$this->excid)) {
			$this->name = "<font color=blue>EX".$this->name."</font>";
			$this->ex = 1;
			$this->exskset();
		}
	}

	public function exskset() {
		return 1;
	}
	
	public function checkar($a) {
		if(method_exists($this,'arskset') && CalHelper::is_arise($a) === true) {
			$this->name = "<font color=red>真·".$this->name."</font>";
			$this->ar = 1;
			$this->arskset();
		}
	}

	public function attk_desc($a,$b) {
		$_SESSION['show'] .= $a->name."对".$b->name."发动".$this->name."<br>";
	}
	
	//行动函数
	public function action_dead($a,$b){
		$_SESSION['show'] .= "<p>";
		$this->attk_desc($a,$b);
		$dres = CalHelper::dead_res_cal($a,$b,$this);
		if($dres >= 0 && $this->ref != 1) {
			$hit = CalHelper::dead_odds_cal($a,$b,$this,$this->dtype);
			$tmp = mt_rand(1,100);
			if($hit >= $tmp) {
				$_SESSION['show'] .= "即死成功！乱数:".$tmp."<br>";
				$alived = CalHelper::alive_proc($this,$b);
				if($alived != 1) {
					$divine_shield = CalHelper::divine_shield($b);
					$hell_stayer = CalHelper::hell_stayer($b);
				}
				if($divine_shield == 1) {
					;;
				} elseif($hell_stayer == 1) {
					;;
				} elseif($alived != 1) {
					CalHelper::apply_damage($a,$b,0,$b->hp);
				}
			} else {
				$_SESSION['show'] .= "即死失败！乱数:".$tmp."<br>";
			}
		} else {
			$_SESSION['show'] .= "即死攻击反射！<br>";
			if($a->isboss != 1) {
				$dres = CalHelper::dead_res_cal($a,$a,$this,$this->dtype);
				if($dres >= 1) $dmg = floor($a->mxhp * 0.75);
				elseif($dres > 0) $dmg = floor($a->mxhp * 0.55);
				elseif($dres == 0) $dmg = floor($a->mxhp * 0.4);
				else $dmg = floor($a->mxhp * 0.3);
				if($dmg > $a->hp) $dmg = $a->hp - 1;
				$_SESSION['show'] .= "伤害：".$dmg."<br>";
				CalHelper::apply_damage($a,$a,0,$dmg);
			}
		}
	}

	public function action_once($a,$b){
		$_SESSION['show'] .= "<p>";
		$this->attk_desc($a,$b);
		$ref_absorb = 0; //反射1 吸收2

		$hit = CalHelper::hit_cal($a,$b,$this);
		$tmp = mt_rand(1,100);
		if ($hit >= $tmp) {
			$_SESSION['show'] .= "命中！乱数:".$tmp."&nbsp;";

			$ref_absorb = CalHelper::ref_absorb_cal($a,$b,$this,$this->atk_type);
			if($this->atk_type == 0) {
				$dmg = CalHelper::phy_dmg_cal($a,$b,$this,$this->atk_type);
			} else {
				$dmg = CalHelper::mgc_dmg_cal($a,$b,$this,$this->atk_type);
			}
			if($ref_absorb > 0) {
				$dmg = CalHelper::refabsorb_dmg_cal($a,$ref_absorb,$this,$dmg);
			} elseif($this->id == 57) { 	//夜叉の貪り特殊处理
				if(!isset($a->maxdmg)) $a->maxdmg = 0;
				$a->maxdmg = ($dmg > $a->maxdmg) ? $dmg : $a->maxdmg; //记录最大的伤害值
			}
			$_SESSION['show'] .= "伤害：".$dmg."<br>";

			CalHelper::apply_damage($a,$b,$ref_absorb,$dmg);
			CalHelper::apply_bonusap($a,$b,$ref_absorb,$dmg,$this);
		}
		else {
			$_SESSION['show'] .= "Miss！乱数:".$tmp."<br>";
		}
		$this->alldmg = $dmg;
		$this->multi = 1;
		if ($dmg > 0 && SkillHelper::isaskill($this) == 1 && $ref_absorb == 0) {
			if(StatusHelper::down($b,$this->res) == 1) {
				CalHelper::judgepoint($a,$b,'DOWN');
			} elseif(SkillHelper::isaskill($this) == 1) {
				CalHelper::judgepoint($a,$b,'DAMAGE');
			}
			if($this->isunique == 1) CalHelper::divine_judge($a,$b,$dmg);	//天の裁定
			if(!$this->noposta) $this->post_action($a,$b);
			if(!$this->nopostd) $this->post_dead($a,$b);
		} elseif($b->hited == 1) {
			CalHelper::judgepoint($a,$b,'VOID');
		}
	}

	public function action_multi($a,$b){
		$_SESSION['show'] .= "<p>";
		$this->attk_desc($a,$b);
		$ref_absorb = 0; //反射1 吸收2
		$multi = mt_rand($this->mint,$this->maxt);
		$this->plus = CalHelper::multi_decay($multi);

		$total_dmg = 0;
		$ref_absorb = CalHelper::ref_absorb_cal($a,$b,$this,$this->atk_type);
		for ($i=1; $i<=$multi; $i++) {
			if ($multi > 1) $_SESSION['show'] .= "第".$i."击&nbsp;";
			if ($multi > 1)
				$hit = CalHelper::hit_cal($a,$b,$this,$multi);
			else
				$hit = CalHelper::hit_cal($a,$b,$this);
			$tmp = mt_rand(1,100);
			if ($hit >= $tmp) {
				$_SESSION['show'] .= "命中！乱数:".$tmp."&nbsp;";

				if($this->atk_type == 0) {
					$dmg = CalHelper::phy_dmg_cal($a,$b,$this,$this->atk_type);
				} else {
					$dmg = CalHelper::mgc_dmg_cal($a,$b,$this,$this->atk_type);
				}
				if($ref_absorb > 0) {
					$dmg = CalHelper::refabsorb_dmg_cal($a,$ref_absorb,$this,$dmg);
				}

				$_SESSION['show'] .= "伤害：".$dmg."<br>";

				CalHelper::apply_damage($a,$b,$ref_absorb,$dmg);
				$total_dmg=($ref_absorb != 1) ? ($total_dmg+$dmg) : 0;
			}
			else {
				$_SESSION['show'] .= "Miss！乱数:".$tmp."<br>";
			}
		}
		CalHelper::apply_bonusap($a,$b,$ref_absorb,$total_dmg,$this);
		$this->alldmg = $total_dmg;
		$this->multi = $multi;
		if ($total_dmg > 0 && $ref_absorb == 0) {
			if(StatusHelper::down($b,$this->res) == 1) {
				CalHelper::judgepoint($a,$b,'DOWN');
			} elseif(SkillHelper::isaskill($this) == 1) {
				CalHelper::judgepoint($a,$b,'DAMAGE');
			}
			if($this->isunique == 1) CalHelper::divine_judge($a,$b,$total_dmg);	//天の裁定
			if(!$this->noposta) $this->post_action($a,$b);
			if(!$this->nopostd) $this->post_dead($a,$b);
		} elseif($b->hited) {
			CalHelper::judgepoint($a,$b,'VOID');
		}
		if ($multi > 1) $_SESSION['show'] .= "总伤害：".$total_dmg."<br>";
	}

	public function post_action($a,$b) {

	}

	public function post_dead($a,$b) {
		$c=1;
		if(!isset($this->exdtype)) return 0;
		if(is_array($this->exdtype)) { 
			$c=count($this->exdtype);
			$clone_exdtype = $this->exdtype;
		}
		for($i=0;$i<$c;$i++) {
		if($b->hp <= 0) return 1;
		if(isset($clone_exdtype)) $this->exdtype = (int)$clone_exdtype[$i];
		if($b->defskill_status[13]->on == 1 && $this->exdtype <= 7) {
			switch($this->dbase) {
			case 40:{$exdmg=round($a->mgr/2);break;}
			case 50:{$exdmg=$a->mgr;break;}
			case 60:{$exdmg=$a->mgr*2;}
			default:{$exdmg=$a->mgr*4;}
			}
			$_SESSION['show'] .= $b->name."佩戴ソロモンの指輪，追加".$exdmg."伤害。<br>";
			CalHelper::apply_damage($a,$b,0,$exdmg);
			continue;
		}
		if(CalHelper::dead_res_cal($a,$b,$this) >= 0) {
			$hit = CalHelper::dead_odds_cal($a,$b,$this,$this->exdtype);
			$tmp = mt_rand(1,100);
			if($hit >= $tmp) {
				$_SESSION['show'] .= "附加即死成功！乱数:".$tmp."<br>";
				$alived = CalHelper::alive_proc($this,$b);
				if($alived != 1) {
					$divine_shield = CalHelper::divine_shield($b);
					$hell_stayer = CalHelper::hell_stayer($b);
				}
				if($divine_shield == 1) {
					CalHelper::apply_damage($a,$b,0,round($b->hp/2));
					$b->ap = 0;
				} elseif($hell_stayer == 1) {
					;;
				} elseif($alived != 1) {
					CalHelper::apply_damage($a,$b,0,$b->hp);
				}
			} else {
				$_SESSION['show'] .= "附加即死失败！乱数:".$tmp."<br>";
			}
		}
		}
	}

	public function final_action($a) {

	}

}

class SingleAttack extends Skill {

	public function __construct() {
		$this->id = -1;
		$this->name = "单体攻击基类";			//技能名称
		$this->type = 0;				//组别
		$this->atk_type = 0;	//0物 1火 2冰 3雷 4地 5风 6光 7暗 8万能

		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->tp = 0;

		$this->pwr = 0;			//基本攻击值
		$this->hits = 0;			//最终命中补正
		$this->ahits = 0;			//异常命中补正
		$this->shits = 0;			//即死命中补正
		$this->crt = 0;				//会心补正

		$this->charge = 1;		//蓄力倍率,包含物理和魔法
		$this->res = 1;			//耐性倍率
		$this->plus = 1;		//复数减成

		$this->tgtnum = 0;		//全体攻击时实际攻击人数,单体固定为0，扩散固定为1,全体默认1、根据实际变化

		$this->maxp = 100;		//随机波动上下限。
		$this->minp = 100;

		$this->maxt = 1;		//攻击次数上下限
		$this->mint = 1;

		$this->thru = 0;		//是否贯通

		$this->all_atk = 0;		//是否万能攻击
		$this->ref = 0;			//是否强制反射

		$this->destroyer = 0; //破坏神加成
		$this->buste = 0; //布斯塔
		$this->hibuste = 0; //海布
		$this->lordg = 0;	//大魔王的加护
		$this->bdress = 0; //黑裙子

	}

	//起始函数，单体攻击型
	public function start($a,$b,$atkid,$defid,$defer) {

		$this->checkex($a[$atkid]);
		$this->checkar($a[$atkid]);
		$sk = clone $this;
		$sk->pre_attack($sk,$a[$atkid],$defer);
		
		CalHelper::cost_cal($a[$atkid],$this);

		/** 对b的防御性技能影响状态数组遍历 **/
		foreach($defer->defskill_status as $dss) {
			if ($dss->on == 1)
				$dss->start($a[$atkid],$defer,$sk);
		}

		$a[$atkid]->hited=$defer->hited=0;
		if($sk->puredead == 1) {
			$sk->action_dead($a[$atkid],$defer);
		}	elseif($sk->mint == 1 && $sk->maxt == 1) {
			$sk->action_once($a[$atkid],$defer);
		} else {
			$sk->action_multi($a[$atkid],$defer);
		}	

		/** 对b的防御性事后状态数组遍历 **/
		if(CalHelper::ifgroupskill($a[$atkid]) == 13 && $a[$atkid]->before_status[17]->started == 1 && $this->oap >= 5 && $defer->hp <= 0) {
				$_SESSION['show'] .= $a[$atkid]->name."发动いけにえの盟約！<br>";
				CalHelper::disillusion($defer);
		} else {
			foreach($defer->defafter_status as $das) {
				if ($das->on == 1)
					$das->action($a[$atkid],$defer,$sk);
			}
		}
		$defer->standing = 0;

		if ($defer->hp <= 0) {
			$defer->hp = 0;
			CalHelper::judgepoint($a[$atkid],$defer,'KILL');
			$this->kill_desc($a[$atkid],$defer);
			$this->spec_kill_desc($a[$atkid],$defer);
			
			if ($a[$atkid]->eventskill_status[1]->on == 1) {
				$a[$atkid]->eventskill_status[1]->action($a[$atkid],$defer);
			}
			if ($a[$atkid]->eventskill_status[2]->on == 1) {
				$a[$atkid]->eventskill_status[2]->action($a[$atkid],$defer);
			}
			if ($a[$atkid]->eventskill_status[24]->on == 1 && $this->atk_type == 0) {
				$a[$atkid]->eventskill_status[24]->action($a[$atkid],$defer);
			}
			
		}
		$a[$atkid]->eventskill_status[3]->action($a[$atkid],$defer,$this);

		/** 对a的防御性事后状态数组遍历 **/
		foreach($a[$atkid]->defafter_status as $aas) {
			if ($aas->on == 1)
				$aas->action($a[$atkid],$a[$atkid]);
		}

		//自杀描述
		if($a[$atkid]->hp <= 0) {
			$this->suicide_desc($a[$atkid]);
		}

		$sk->final_action($a[$atkid]);
	}

}

class AllAttack extends Skill {

	public function __construct() {
		$this->id = -1;
		$this->name = "全体攻击基类";			//技能名称
		$this->type = 0;				//组别
		$this->atk_type = 0;	//0物 1火 2冰 3雷 4地 5风 6光 7暗 8万能

		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->tp = 0;

		$this->pwr = 50;			//基本攻击值
		$this->hits = 0;			//最终命中补正
		$this->ahits = 0;			//异常命中补正
		$this->shits = 0;			//即死命中补正
		$this->crt = 0;				//会心补正

		$this->charge = 1;		//蓄力倍率,包含物理和魔法
		$this->res = 1;			//耐性倍率
		$this->plus = 1;		//复数减成

		$this->tgtnum = 1;		//全体攻击时实际攻击人数,单体固定为0，扩散固定为1,全体默认1、根据实际变化

		$this->maxp = 100;		//随机波动上下限。
		$this->minp = 100;

		$this->maxt = 1;		//攻击次数上下限
		$this->mint = 1;

		$this->thru = 0;		//是否贯通

		$this->all_atk = 0;		//是否万能攻击
		$this->ref = 0;			//是否强制反射

	}

	//起始函数，全体攻击型
	public function start($a,$b,$atkid,$defid,$defer) {

		$this->checkex($a[$atkid]);
		$this->checkar($a[$atkid]);
		$this->tgtnum = CalHelper::live_count($b);
		CalHelper::cost_cal($a[$atkid],$this);

		foreach($b as $d) {
			if ($d->hp <= 0 || $d->talked == 1 || $d->escaping == 1) continue;
			$sk = clone $this;
			$sk->pre_attack($sk,$a[$atkid],$d);
			/** 对b的防御性技能影响状态数组遍历 **/
			foreach($d->defskill_status as $dss) {
				if ($dss->on == 1)
					$dss->start($a[$atkid],$d,$sk);
			}

			$a[$atkid]->hited=$d->hited=0;
			if($sk->puredead == 1) {
				$sk->action_dead($a[$atkid],$d);
			} elseif($sk->mint == 1 && $sk->maxt == 1) {
				$sk->action_once($a[$atkid],$d);
			} else {
				$sk->action_multi($a[$atkid],$d);
			}	

			/** 对b的防御性事后状态数组遍历 **/
			if(CalHelper::ifgroupskill($a[$atkid]) == 13 && $a[$atkid]->before_status[17]->started == 1 && $this->oap >= 5 && $defer <= 0) {
					$_SESSION['show'] .= $a[$atkid]->name."发动いけにえの盟約！<br>";
					CalHelper::disillusion($d);
			} else {
				foreach($d->defafter_status as $das) {
					if ($das->on == 1)
						$das->action($a[$atkid],$d,$sk);
				}
			}
			$d->standing = 0;

			if ($d->hp <= 0) {
				$d->hp = 0;				
				CalHelper::judgepoint($a[$atkid],$d,'KILL');
				$this->kill_desc($a[$atkid],$d);
				$this->spec_kill_desc($a[$atkid],$d);
				if ($a[$atkid]->eventskill_status[1]->on  == 1) {
					$a[$atkid]->eventskill_status[1]->action($a[$atkid],$d);
				}
				if ($a[$atkid]->eventskill_status[2]->on == 1) {
					$a[$atkid]->eventskill_status[2]->action($a[$atkid],$d);
				}
				if ($a[$atkid]->eventskill_status[24]->on == 1 && $this->atk_type == 0) {
					$a[$atkid]->eventskill_status[24]->action($a[$atkid],$d);
				}
			}
			$a[$atkid]->eventskill_status[3]->action($a[$atkid],$d,$this);

			$_SESSION['show'] .= "<p>";
		}

		/** 对a的防御性事后状态数组遍历 **/
		foreach($a[$atkid]->defafter_status as $aas) {
			if ($aas->on == 1)
				$aas->action($a[$atkid],$a[$atkid]);
		}

		//自杀描述
		if($a[$atkid]->hp <= 0) {
			$this->suicide_desc($a[$atkid]);
		}

		$this->final_action($a[$atkid]);
	}

}

class SpreadAttack extends Skill {

	public function __construct() {
		$this->id = -1;
		$this->name = "扩散攻击基类";			//技能名称
		$this->type = 0;				//组别
		$this->atk_type = 0;	//0物 1火 2冰 3雷 4地 5风 6光 7暗 8万能

		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->tp = 0;

		$this->pwr = 0;			//基本攻击值
		$this->hits = 0;			//最终命中补正
		$this->ahits = 0;			//异常命中补正
		$this->shits = 0;			//即死命中补正
		$this->crt = 0;				//会心补正

		$this->charge = 1;		//蓄力倍率,包含物理和魔法
		$this->res = 1;			//耐性倍率
		$this->plus = 1;		//复数减成

		$this->maxp = 100;		//随机波动上下限。
		$this->minp = 100;

		$this->maxt = 1;		//攻击次数上下限
		$this->mint = 1;

		$this->tgtnum = 1;		//全体攻击时实际攻击人数

		$this->thru = 0;		//贯通
		$this->defbreak = 0;	//破防

		$this->all_atk = 0;		//万能攻击
		$this->ref = 0;			//强制反射

	}


	//起始函数，扩散型
	public function start($a,$b,$atkid,$defid,$defer) {

		if($this->id == 602 && $a[$atkid]->eventskill_status[24]->on == 0) {
			$_SESSION['show'] .= $a[$atkid]->name."进入雪華准备状态。<br>";
			$a[$atkid]->eventskill_status[24]->on = 1;
			return 1;
		}
		CalHelper::cost_cal($a[$atkid],$this);
		$s = clone $this;
		$s->pre_attack($s,$a[$atkid],$defer);

		/** ===================  主目标处理  ================= **/
		$sk = clone $s;
		foreach($defer->defskill_status as $dss) {
			if ($dss->on == 1)
				$dss->start($a[$atkid],$defer,$sk);
		}

		$a[$atkid]->hited=$defer->hited=0;
		if($sk->puredead == 1) {
			$sk->action_dead($a[$atkid],$defer);
		} elseif($sk->mint == 1 && $sk->maxt == 1) {
			$sk->action_once($a[$atkid],$defer);
		} else {
			$sk->action_multi($a[$atkid],$defer);
		}	

		foreach($defer->defafter_status as $das) {
			if ($das->on == 1)
				$das->action($a[$atkid],$defer,$sk);
		}
		$defer->standing = 0;

		if ($defer->hp <= 0) {
			$defer->hp = 0;
			$this->kill_desc($a[$atkid],$defer);
			$this->spec_kill_desc($a[$atkid],$defer);
			if ($a[$atkid]->eventskill_status[1]->on  == 1) {
				$a[$atkid]->eventskill_status[1]->action($a[$atkid],$defer);
			}
			if ($a[$atkid]->eventskill_status[2]->on == 1) {
				$a[$atkid]->eventskill_status[2]->action($a[$atkid],$defer);
			}
			if ($a[$atkid]->eventskill_status[24]->on == 1 && $this->atk_type == 0) {
				$a[$atkid]->eventskill_status[24]->action($a[$atkid],$defer);
			}
		}
		$a[$atkid]->eventskill_status[3]->action($a[$atkid],$defer,$this);

		$_SESSION['show'] .= "<p>";
		if($sk->alldmg <= 0) return;
		$s->multi = $sk->multi;
		/** ===================  扩散目标处理  ================= **/
		$s->tgtnum = CalHelper::live_count($b);
		foreach($b as $d) {
			if ($d->hp <= 0 || $d == $defer || $d->talked == 1) continue;
			$sk = clone $s;

			/** 对b的防御性技能影响状态数组遍历 **/
			foreach($d->defskill_status as $dss) {
				if ($dss->on == 1)
					$dss->start($a[$atkid],$d,$sk);
			}

			$a[$atkid]->hited=$d->hited=0;
			$sk->action_other($a[$atkid],$d);

			/** 对b的防御性事后状态数组遍历 **/
			foreach($d->defafter_status as $das) {
				if ($das->on == 1)
					$das->action($a[$atkid],$d);
			}
			$d->standing = 0;

			if ($d->hp <= 0) {
				$d->hp = 0;
				$this->kill_desc($a[$atkid],$d);
				$this->spec_kill_desc($a[$atkid],$d);
				if ($a[$atkid]->eventskill_status[1]->on  == 1) {
					$a[$atkid]->eventskill_status[1]->action($a[$atkid],$d);
				}
				if ($a[$atkid]->eventskill_status[2]->on == 1) {
					$a[$atkid]->eventskill_status[2]->action($a[$atkid],$d);
				}
				if ($a[$atkid]->eventskill_status[24]->on == 1 && $this->atk_type == 0) {
					$a[$atkid]->eventskill_status[24]->action($a[$atkid],$d);
				}
			}
			$a[$atkid]->eventskill_status[3]->action($a[$atkid],$d,$this);

			$_SESSION['show'] .= "<p>";
		}
		/** 对a的防御性事后状态数组遍历 **/
		foreach($a[$atkid]->defafter_status as $aas) {
			if ($aas->on == 1)
				$aas->action($a[$atkid],$a[$atkid]);
		}

		//自杀描述
		if($a[$atkid]->hp <= 0) {
			$this->suicide_desc($a[$atkid]);
		}

		$this->final_action($a[$atkid]);
	}

	//行动函数
	public function action_other($a,$b) {

		$_SESSION['show'] .= $a->name."的".$this->name."波及到了".$b->name."。<br>";
		$ref_absorb = 0; //反射1 吸收2
		$multi = $this->multi;
		$this->plus = CalHelper::multi_decay($multi);

		$total_dmg = 0;
		for ($i=1; $i<=$multi; $i++) {
			if ($multi > 1) $_SESSION['show'] .= "第".$i."击;";
			if ($multi > 1)
				$hit = CalHelper::hit_cal($a,$b,$this,$multi);
			else
				$hit = CalHelper::hit_cal($a,$b,$this);
			$tmp = mt_rand(1,100);
			if ($hit >= $tmp) {
				$_SESSION['show'] .= "命中！乱数:".$tmp."&nbsp;";

				$ref_absorb = CalHelper::ref_absorb_cal($a,$b,$this,$this->atk_type);

				if($this->atk_type == 0) {
					$dmg = CalHelper::phy_dmg_cal($a,$b,$this,$this->atk_type);
				} else {
					$dmg = CalHelper::mgc_dmg_cal($a,$b,$this,$this->atk_type);
				}
				if($ref_absorb > 0) {
					$dmg = CalHelper::refabsorb_dmg_cal($a,$ref_absorb,$this,$dmg);
				}
				$dmg = round($dmg * 0.5);

				$_SESSION['show'] .= "伤害：".$dmg."<br>";

				CalHelper::apply_damage($a,$b,$ref_absorb,$dmg);
				$total_dmg=($ref_absorb == 0) ? ($total_dmg + $dmg) : 0;
			}
			else {
				$_SESSION['show'] .= "Miss！乱数:".$tmp."<br>";
			}
		}
		if ($dmg > 0) {
			StatusHelper::down($b,$this->res);
		}
		if ($multi > 1) $_SESSION['show'] .= "总伤害：".$total_dmg."<br>";
	}
	
}

class GroundAttack extends Skill {

	public function __construct() {
		$this->id = -1;
		$this->name = "全场攻击基类";			//技能名称
		$this->type = 0;				//组别
		$this->atk_type = 0;	//0物 1火 2冰 3雷 4地 5风 6光 7暗 8万能

		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->tp = 0;

		$this->pwr = 50;			//基本攻击值
		$this->hits = 0;			//最终命中补正
		$this->ahits = 0;			//异常命中补正
		$this->shits = 0;			//即死命中补正
		$this->crt = 0;				//会心补正

		$this->charge = 1;		//蓄力倍率,包含物理和魔法
		$this->res = 1;			//耐性倍率
		$this->plus = 1;		//复数减成

		$this->tgtnum = 1;		//全体攻击时实际攻击人数,单体固定为0，扩散固定为1,全体默认1、根据实际变化

		$this->maxp = 100;		//随机波动上下限。
		$this->minp = 100;

		$this->maxt = 1;		//攻击次数上下限
		$this->mint = 1;

		$this->thru = 0;		//是否贯通

		$this->all_atk = 0;		//是否万能攻击
		$this->ref = 0;			//是否强制反射

	}

	//起始函数，全场攻击型
	public function start($a,$b,$atkid,$defid,$defer) {

		$c = array_merge($a,$b);
		$this->checkex($a[$atkid]);
		$this->checkar($a[$atkid]);
		$this->tgtnum = CalHelper::live_count($c);
		CalHelper::cost_cal($a[$atkid],$this);

		foreach($c as $d) {
			if ($d->hp <= 0 || $d == $a[$atkid] || $d->talked == 1 || $d->escaping == 1) continue;
			$sk = clone $this;
			$sk->pre_attack($sk,$a[$atkid],$defer);
			/** 对b的防御性技能影响状态数组遍历 **/
			foreach($d->defskill_status as $dss) {
				if ($dss->on == 1)
					$dss->start($a[$atkid],$d,$sk);
			}

			$a[$atkid]->hited=$d->hited=0;
			if($sk->puredead == 1) {
				$sk->action_dead($a[$atkid],$d);
			} elseif($sk->mint == 1 && $sk->maxt == 1) {
				$sk->action_once($a[$atkid],$d);
			} else {
				$sk->action_multi($a[$atkid],$d);
			}	

			/** 对b的防御性事后状态数组遍历 **/
			if(CalHelper::ifgroupskill($a[$atkid]) == 13 && $a[$atkid]->before_status[17]->started == 1 && $this->oap >= 5 && $defer->hp <= 0) {
					$_SESSION['show'] .= $a[$atkid]->name."发动いけにえの盟約！<br>";
					CalHelper::disillusion($d);
			} else {
				foreach($d->defafter_status as $das) {
					if ($das->on == 1)
						$das->action($a[$atkid],$d,$sk);
				}
			}

			if ($d->hp <= 0) {
				$d->hp = 0;				
				CalHelper::judgepoint($a[$atkid],$d,'KILL');
				$this->kill_desc($a[$atkid],$d);
				$this->spec_kill_desc($a[$atkid],$d);
				if ($a[$atkid]->eventskill_status[1]->on  == 1) {
					$a[$atkid]->eventskill_status[1]->action($a[$atkid],$d);
				}
				if ($a[$atkid]->eventskill_status[2]->on == 1) {
					$a[$atkid]->eventskill_status[2]->action($a[$atkid],$d);
				}
				if ($a[$atkid]->eventskill_status[24]->on == 1 && $this->atk_type == 0) {
					$a[$atkid]->eventskill_status[24]->action($a[$atkid],$d);
				}
			}
			$a[$atkid]->eventskill_status[3]->action($a[$atkid],$d,$this);

			$_SESSION['show'] .= "<p>";
		}
		/** 对a的防御性事后状态数组遍历 **/
		foreach($a[$atkid]->defafter_status as $aas) {
			if ($aas->on == 1)
				$aas->action($a[$atkid],$a[$atkid]);
		}

		//自杀描述
		if($a[$atkid]->hp <= 0) {
			$this->suicide_desc($a[$atkid]);
		}

		$this->final_action($a[$atkid]);
	}

}

require_once("physkill_class.php");
require_once("mgcskill_class.php");

?>
